#include "ET++.ph"
#ifdef __GNUG__
#pragma implementation
#endif

#include "Printer.h"

#include "Class.h"
#include "String.h"
#include "Window.h"
#include "VObject.h"
#include "BorderItems.h"
#include "PrintPort.h"
#include "Progress.h"
#include "PrintManager.h"
#include "Menu.h"
#include "Box.h"

//---- Printer -----------------------------------------------------------------

NewMetaImpl(Printer, Object, (TP(pdia), TP(settings)));

Printer::Printer()
{
	pdia= 0;
}

const char *Printer::GetName()
{
	return "GENERIC";
}

const char *Printer::AsString()
{
	return GetName();
}

Printer::~Printer()
{
	//SafeDelete(pdia);
	SafeDelete(settings);
}

PrintPort *Printer::MakePrintPort(const char*)
{
	return new PrintPort;
}

bool Printer::CanPrint()
{
	return FALSE;
}

bool Printer::CanSave()
{
	return FALSE;
}

VObject *Printer::GetOptions()
{
	if (pdia == 0) {
		pdia= DoCreatePrintDialog();
		if (pdia)
			pdia= new VExpander(gPoint0, new Separator, new Matte(pdia), 0);
	}
	return pdia;
}

bool Printer::OpenPage(int pageno, Rectangle)
{
	gProgress->SetMessage(form("Printing Page %d", pageno));
	return FALSE;
}

bool Printer::ClosePage()
{
	return gProgress->Inc(1);
}

void Printer::Start(int pagecnt)
{
	gProgress->Start("Printing", pagecnt);
}

void Printer::Finish()
{
	gProgress->Stop();
}

PrinterSettings *Printer::MakeSettings()
{
	return new PrinterSettings(Point(595, 842), Point(50), Point(50), gRect0);
}

PrinterSettings *Printer::GetSettings()
{
	if (settings == 0) {
		settings= MakeSettings();
		settings->name= GetName();
	}
	return settings;
}

VObject *Printer::DoCreatePrintDialog()
{
	return 0;
}

void Printer::LoadSettings(PrinterSettings*)
{
}

void Printer::StoreSettings(PrinterSettings*)
{
}

